var Page = function(){
    this.init();
};
Page.prototype = {
    params: {
        passport: '',
        sysId:''
    },
    init: function(){
        this.initParams();
        this.initEvent();
    },
    initParams: function(){
        this.params.passport = Pub.getCookie('_PASSPORT');
        this.params.sysId = Pub.getSession('sysId');
    },
    getData: function(){
        var _this = this;
        var paramsObj = {
            passport: _this.params.passport,
            sysId:_this.params.sysId
        };
        console.log(paramsObj);
        Api.newnumericaldetails(paramsObj, function(data){
            console.log(data);
            // $('#title').text(data.key+'编辑');
            $('#numType').val(data.keyName);
            $('#value').val(data.value);
            $('#note').val(data.describe);
            if (data.is_enable==0) {
                honeySwitch.showOff("#isEnable");
            };
        });
    },
    submit:function(){
        var _this = this;
        $('#submit').click(function(event) {
            var value=$('#value').val();
            var describe=$('#note').val();
            // if ($('#isEnable').hasClass('switch-on')) {
            //     var isEnable=1;
            // }else{
            //     var isEnable=0;
            // };
            var paramsObj = {
                passport: _this.params.passport,
                sysId:_this.params.sysId,
                value:value,
                describe:describe,
                isEnable:1
            };
            console.log(paramsObj);
            Api.newnumericalmodify(paramsObj, function(data){
                console.log(data);
                layui.use('layer', function(){
                    layer.msg('编辑成功', {icon: 6});
                    setTimeout(function(){
                        window.location.href = Pub.getHtmlUrl('./numerical-set.html');
                    },1500)
                });
            });

        });
    },
    otherEvent:function(){
        var _this = this;
        $('.goods-checkbox input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        })

    },
    initEvent: function(){
        var _this = this;
         _this.getData();
        _this.otherEvent();
        _this.submit();

    }
};
var page = new Page();